<?php

/*
 * 文章页控制器
 */
class ArchiveAction extends Action{
    function index($id){
        
        $map['id'] = $id;
        $m = M('archive');
        $field = $m->where($map)->join('__ARCHIVEBODY__ AS body on body.aid=__ARCHIVE__.id')->find();
        //上一页，下一页
        $map['typeid'] = $field['typeid'];
        $map['id'] = array('gt',$field['id']);
        $_next = $m->where($map)->order('id asc')->find();
        if($_next){$next = '<a href="'.U('Home/Archive/index',array('id'=>$_next['id'])).'" style="color:#929393">'.$_next['title'].'</a> ';}else{$next = '没有啦';}
        $map['id'] =array('lt',$field['id']);
        $_pre = $m->where($map)->order('id desc')->find();
        if($_pre){$pre = '<a href="'.U('Home/Archive/index',array('id'=>$_pre['id'])).'" style="color:#929393">'.$_pre['title'].'</a> ';}else{$pre = '没有啦';}
        $this->assign('field',$field);
        $this->assign('next',$next);
        $this->assign('pre',$pre);
        //相关资讯
        unset($field['body']);
        C('archive',$field);//装载进常量中，便于（相关资讯）标签中调用
        //得到当前模板
        $type = M('arctype')->find($field['typeid']);
        $this->assign('type',$type);
        $temp = $type['temparticle'];
        $this->display(C('MYTEMP').'/'.$temp);
    }
}